Skip to content

windows: normalize drive letters fixes #9279#9313

Merged
ThomasWaldmann merged 1 commit intoborgbackup:masterfrom
trxvorr:fix-9279-drive-letters
Feb 14, 2026
Merged

windows: normalize drive letters fixes #9279#9313
ThomasWaldmann merged 1 commit intoborgbackup:masterfrom
trxvorr:fix-9279-drive-letters

Conversation

@trxvorr
Copy link
Contributor

@trxvorr trxvorr commented Feb 13, 2026

Implemented drive letter normalization in make_path_safe within src/borg/helpers/fs.py.

Windows drive letters (e.g. C:\path) are now mapped to portable path components (e.g. C/path) to ensure cross-platform compatibility and correct archiving.

Added regression test test_make_path_safe_win32_drive_letters to src/borg/testsuite/helpers/fs_test.py covering various drive letter scenarios.

Verified locally on Windows with MSYS2. Fixes #9279

@trxvorr
Copy link
Contributor Author

trxvorr commented Feb 13, 2026

@ThomasWaldmann I verified map_chars with test_windows_paths.py it correctly maps special characters like *, ?, | to the private use area

@ThomasWaldmann
Copy link
Member

Thanks for the PR!

I see some formatting changes - are you using the black version as specified in requirements.d/*.txt?

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.93%. Comparing base (2b5bca4) to head (6430564).
⚠️ Report is 7 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9313   +/-   ##
=======================================
  Coverage   75.92%   75.93%           
=======================================
  Files          86       86           
  Lines       14777    14780    +3     
  Branches     2201     2202    +1     
=======================================
+ Hits        11220    11223    +3     
  Misses       2880     2880           
  Partials      677      677           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trxvorr trxvorr force-pushed the fix-9279-drive-letters branch from 8a62fd8 to bbe2a22 Compare February 13, 2026 04:44
@trxvorr
Copy link
Contributor Author

trxvorr commented Feb 13, 2026

@ThomasWaldmann Yes, sorry about that!
I previously used a newer version of black.
I have just updated to black 24.10.0 (as per requirements.d/codestyle.txt), reformatted the code, and force-pushed the changes.

@trxvorr trxvorr force-pushed the fix-9279-drive-letters branch 3 times, most recently from adb91e7 to 53266d5 Compare February 13, 2026 19:19
@trxvorr trxvorr force-pushed the fix-9279-drive-letters branch 3 times, most recently from 8e03551 to 5f7a0c8 Compare February 13, 2026 22:56
@ThomasWaldmann
Copy link
Member

Please also do some manual tests on windows, using borg create, list, extract.

Use different absolute paths, use different drive letters (current drive, other drive).

@trxvorr trxvorr force-pushed the fix-9279-drive-letters branch 2 times, most recently from 491d9eb to 189fe68 Compare February 14, 2026 14:46
@trxvorr trxvorr force-pushed the fix-9279-drive-letters branch from 189fe68 to 6430564 Compare February 14, 2026 14:53
@trxvorr
Copy link
Contributor Author

trxvorr commented Feb 14, 2026

Did some manual testing:

Test 1: borg create with absolute C:/ paths

$ borg create --list ::test-cdrive C:/Users/trevo/Desktop/Projects/borg/test_drive_letters.py C:/Users/trevo/Desktop/Projects/borg/test_windows_paths.py
A C:/Users/trevo/Desktop/Projects/borg/test_drive_letters.py
A C:/Users/trevo/Desktop/Projects/borg/test_windows_paths.py

Test 2: borg list — Verify path storage

$ borg list ::test-cdrive
-rw-rw-rw- root root 1568 Fri, 2026-02-13 06:58:23 +0530 C/Users/trevo/Desktop/Projects/borg/test_drive_letters.py
-rw-rw-rw- root root 5612 Fri, 2026-02-13 06:46:04 +0530 C/Users/trevo/Desktop/Projects/borg/test_windows_paths.py

C: correctly normalized to C/

Test 3: borg extract — Verify restoration

$ mkdir output && cd output && borg extract ::test-cdrive
$ find . -type f
./C/Users/trevo/Desktop/Projects/borg/test_drive_letters.py
./C/Users/trevo/Desktop/Projects/borg/test_windows_paths.py

Files extracted under C/ directory, contents intact

Test 4: Relative paths (no drive letter)

$ borg create --list ::test-relative test_drive_letters.py test_windows_paths.py
$ borg list ::test-relative
-rw-rw-rw- root root 1568 ... test_drive_letters.py
-rw-rw-rw- root root 5612 ... test_windows_paths.py

No drive prefix added for relative paths

Test 5: /tmp path (resolves to C:/msys64/tmp/)

$ borg create --list ::test-tmpdir /tmp/borg_manual_test/input
A C:/msys64/tmp/borg_manual_test/input/file1.txt
A C:/msys64/tmp/borg_manual_test/input/subdir/nested.txt
A C:/msys64/tmp/borg_manual_test/input/file2.txt

$ borg list ::test-tmpdir
drwxrwxrwx root root    0 ... C/msys64/tmp/borg_manual_test/input
-rw-rw-rw- root root   19 ... C/msys64/tmp/borg_manual_test/input/file1.txt
-rw-rw-rw- root root   13 ... C/msys64/tmp/borg_manual_test/input/file2.txt
-rw-rw-rw- root root   12 ... C/msys64/tmp/borg_manual_test/input/subdir/nested.txt

$ cd output2 && borg extract ::test-tmpdir && find . -type f
./C/msys64/tmp/borg_manual_test/input/file1.txt
./C/msys64/tmp/borg_manual_test/input/file2.txt
./C/msys64/tmp/borg_manual_test/input/subdir/nested.txt

Absolute path through MSYS2 correctly normalized, extract works

Note on different drive letters

I don't have a second physical drive to test with. The unit tests cover C:, D:, E:, and F: drive letters.

@ThomasWaldmann
Copy link
Member

That is a bit unusual, but guess it is not due to your changes in this PR:

$ borg create --list ::test-tmpdir /tmp/borg_manual_test/input
A C:/msys64/tmp/borg_manual_test/input/file1.txt

So is /tmp a symlink to /msys64/tmp?

Maybe file an issue for this, guess this should be C/tmp/... in the archive.

Copy link
Member

@ThomasWaldmann ThomasWaldmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ThomasWaldmann
Copy link
Member

OK, merge?

@trxvorr
Copy link
Contributor Author

trxvorr commented Feb 14, 2026

That is a bit unusual, but guess it is not due to your changes in this PR:
$ borg create --list ::test-tmpdir /tmp/borg_manual_test/input
A C:/msys64/tmp/borg_manual_test/input/file1.txt
So is /tmp a symlink to /msys64/tmp?
Maybe file an issue for this, guess this should be C/tmp/... in the archive.

Ill check this out right now and open an issue

@ThomasWaldmann ThomasWaldmann merged commit e60874e into borgbackup:master Feb 14, 2026
19 checks passed
@ThomasWaldmann
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

windows: drive letters (borg2)

2 participants